import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;


	

public class DataReader {
	BufferedReader bufReader;
	String filename;
	
	public boolean SetFilename(String name){
		filename = name;
		File file = new File(name);
		try{
			bufReader = new BufferedReader(new FileReader(file));			
		}
		catch(IOException e){
			e.printStackTrace();			
			return false;
		}
		
		return true;
	}
	
	
	public void ReadMedianArray(int []array){
		File file = new File("D:\\algorithm\\wk6\\Median.txt");
		BufferedReader reader = null;
		try{
			reader = new BufferedReader(new FileReader(file));
			String str = null;
			int i = 0;
			
			while((str = reader.readLine()) != null)
			{
				array[i++] = Integer.parseInt(str);
			}
			reader.close();
		}catch (IOException e){
			e.printStackTrace();
		}finally{
			if(reader != null){
				try{
					reader.close();
				}catch (IOException e2){
					
				}
			}
		}
	}
	
	
	public String GetNextLine(){
		String str = null;
		try{
		str = bufReader.readLine();
		}catch(IOException e){
			e.printStackTrace();
		}
		
		return str;
	}	

}
